#![no_std]
#![no_main]

use core::{arch::asm, panic::PanicInfo};
#[unsafe(no_mangle)]
extern "C" fn _start() {
    let hello = "hello rust!!!\n";
    let eax = print(hello);
    exit();
    
}

#[unsafe(no_mangle)]
extern "C" fn exit() {
    unsafe {
        asm!("xor ebx,ebx", "int $0x80",
                in("eax") 1,
        )
    }
}
#[unsafe(no_mangle)]
extern "C" fn print(ptr:&str) ->i32{
    let mut eax:i32 = 4;
    unsafe {
        asm!(
            "mov eax,4",
            "mov ebx,1",
            "int 0x80",
            out("eax") eax,
            in("ecx") ptr.as_ptr(),
            in("edx") ptr.len(),
        );
    }
     eax
}

#[unsafe(link_section = ".no.use")]
#[panic_handler]
fn panic_handler(_: &PanicInfo) -> ! {
    loop {}
}
